<include file="Public/head" />
<include file="Public/menu" />
<include file="Article/menu" />
<!-- 详情页 -->
<div class="indexBox">
    <style type="text/css">
        .picbox{
            display:inline-block;
            width:108px;
            height:108px;
            position:relative;
        }
        .pic{
            width:100px;
            height:100px;
            position:absolute;
            top:8px;
        }
        .delpic{
            position:absolute;
            left:92px;
        }
    </style>
    <script type="text/javascript">
        $(function(){
            $(".idTabs").idTabs();
        });
        // 图片删除
        function delPic(picId){
            if(picId == ""){
                return ;
            }
            $.post("{:U('Article/delPic')}", "id="+picId, function(result){
                if(result != 0){
                    getPic("{$data.id}");
                }
            }, "text");
        }
        function getPic(articleId){
            var articleId = arguments[0] ? arguments[0] : "";
            if(articleId == ""){
                return ;
            }
            $.post("{:U('Article/getPic')}", "id="+articleId, function(result){
                var _out = "";
                if(result.pics != 0){
                    $.each(result.pic, function(k,v){
                        _out += "<div class='picbox'>";
                        _out += "<img src='"+"__UPLOAD__/{$Think.CONTROLLER_NAME}/"+v.picture+"' class='pic' />";
                        _out += "<img src='__PUBLIC__/Admin/images/action_stop.png' class='delpic' picid='"+v.id+"' />";
                        _out += "</div>";
                    });
                }
                else{
                    _out = "还没有添加图片";
                }
                $("#pictd").html(_out);
                $("#pictd").attr("pics", result.pics);
            }, "json");
        }
        getPic("{$data.id}");
        $(function(){
            $("#pictd").delegate(".delpic","click",function(){
                delPic($(this).attr("picid"));
                getPic("{$data.id}");
            });
        });
    </script>
    <div class="idTabs">
        <ul class="tab">
            <li><a href="#main">添加/编辑文章内容</a></li>
            <li><a href="#mains">添加/编辑文章图片</a></li>
        </ul>
        <div class="items">
            <div id="main">
                <form action="{:U('Article/doEdit')}" method="post">
                    <table width="100%" border="0" cellpadding="8" cellspacing="0" class="tableBasic">
                        <tbody>
                            <tr>
                                <th width="131">名称</th>
                                <th>内容</th>
                            </tr>
                            <tr>
                                <td align="right">文章标题</td>
                                <td>
                                    <input type="text" name="title" value="{$data.title}" size="80" class="inpMain" />
                                </td>
                            </tr>
                            <tr>
                                <td align="right">文章内容</td>
                                <td>
                                    <textarea name="content" cols="79" rows="8" 
                                    class="inpMain" />{$data.content}</textarea>
                                </td>
                            </tr>
                            <tr id="pictr">
                                <td align="right">图片展示</td>
                                <td id="pictd" pics="0">
                                </td>
                            </tr>
                            <tr>
                                <td align="right">作者</td>
                                <td>
                                    <input type="text" name="author" value="{$data.author}" placeholder="{$_SESSION['id']}" size="22"
                                    class="inpMain">
                                </td>
                            </tr>
                            <tr>
                                <td align="right">发表日期</td>
                                <td>
                                    <input name="pubtime" value="{$data.pubtime}" placeholder="请输入发表日期"  class="laydate-icon" onclick="laydate()">
                                </td>
                            </tr>
                            <tr>
                                <td align="right">阅读量</td>
                                <td>
                                    <input type="text" name="views" value="{$data.views|default="0"}" class="inpMain" > 
                                </td>
                            </tr>
                            <tr>
                                <td align="right">分类</td>
                                <td>
                                <select class="" name="cate_id" id="cate_id">
                                    <volist name="cate" id="v">
                                        <option value="{$v.id}">
                                        {$v.name}
                                        </option>
                                    </volist>
                                </select>
                                </td>
                            </tr>
                            <tr>
                                <td colspan="2" align="center">
                                    <input type="hidden" name="id" value="{$data.id}" />
                                    <input name="submit" class="btn" type="submit" value="提交" />
                                </td>
                            </tr>
                        </tbody>
                    </table>
                </form>
            </div>
        </div>
        <div class="items">
            <div id="mains">
                <form action="{:U('Article/doPhoto')}" method="post" enctype="multipart/form-data">
                    <table width="100%" border="0" cellpadding="8" cellspacing="0" class="tableBasic"">
                        <tbody>
                            <tr>
                                <th width="131">名称</th>
                                <th>内容</th>
                            </tr>
                           <tr>
                                <td align="right">文章序号</td>
                                <td>
                                    <input type="text" name="article_id" value="{$data.id}" size="80" class="inpMain" />
                                </td>
                            </tr>
                            <tr id="pictr">
                                <td align="right">图片展示</td>
                                <td id="pictd" pics="0">
                                </td>
                            </tr>
                            <tr>
                                <td align="right">上传文件</td>
                                <td>
                                    <input type="file" name="picture[]" multiple />
                                </td>
                            </tr>
                            <tr>
                                <td colspan="2" align="center">
                                    <input type="submit" name="submit" class="btn" value="保存" />
                                    <input type="hidden" name="id" value="{$data.id}" />
                                </td>
                            </tr>
                        </tbody>
                    </table>
                </form>
            </div>
        </div>
<include file="Public/footer" />